using CGF;
using UnityEngine;
using UnityEngine.UI;

public class Navigation : MonoBehaviour
{
    public CButton[] btns = new CButton[4];

    private void Awake()
    {
        for (int i = 0; i < btns.Length; i++)
        {
            int index = i;
            btns[i].SetClick(() =>
            {
                RootComponent.instance.GetComponent<GameUI>().SwitchTab(index);
            });
        }
    }

    public void SetIndex(int index)
    {
        for (int i = 0; i < btns.Length; i++)
        {
            btns[i].enabled = i != index;
            Color color = i == index ? ColorHelper.Color("#AE7FFA") : Color.white;
            btns[i].GetComponent<Text>().color = color;
            btns[i].transform.GetChild(0).GetComponent<Image>().color = color;
        }
    }
}
